package com.liukang.search.web;

import com.liukang.common.dto.PageDTO;
import com.liukang.search.pojo.ItemDoc;
import com.liukang.search.pojo.RequestParams;
import com.liukang.search.service.ISearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("search")
public class SearchController {
    @Autowired
    private ISearchService searchService;

    @PostMapping("/list")
    public PageDTO<ItemDoc> searchList(@RequestBody RequestParams params){
        return searchService.searchList(params);
    }
    @PostMapping("/filters")
    public Map<String,List<String>> searchFilters(@RequestBody RequestParams params){
        return searchService.searchFilters(params);
    }
    @GetMapping("/suggestion")
    public List<String> getSuggestions(@RequestParam("key") String str){
        return searchService.getSuggestions(str);
    }
}
